<template>
	<view>
		<view class="userLabel" v-for="item in userList" :key="index">
			<view class="itemUser">
				<view class="userName" style="font-size: 34upx;">{{ item.name }}</view>
				<view class="userName" style="color: #A6A6A6;font-size: 30upx;">{{ item.cardId }}</view>
			</view>
			<view class="imgBody">
				<view class="modifyView" style="margin-right: 30upx;"><image @click="userInfo" :data-userinfo="item" src="@/static/img/modify.png" mode=""></image></view>
				<view class="modifyView"><image @click="deleUser" :data-userid="item.id" src="@/static/img/del.png" mode=""></image></view>
			</view>
		</view>
		<view class="addUser" @click="addUser">新增乘车人</view>
	</view>
</template>

<script>
import value from '@/static/value/value.js';
import utils from '@/static/common/utils.js';
export default {
	data() {
		return {
			userList: []
		};
	},
	mounted() {},
	onShow() {
		this.getData();
	},
	methods: {
		getData() {
			const that = this;
			let obj = {
				ticks: this.$ut.GetTicks(),
				channel: 'Xcx'
			};
			obj.sign = this.$ut.GetSign(obj);
			this.$http
				.request({
					url: `/Member/GetTakeManInfo`,
					method: 'get',
					data: obj
				})
				.then(res => {
					if (!res.data.result) {
						return;
					}
					that.userList = res.data.takemanInfos;
				})
				.catch(err => {
					console.log(err);
				});
		},
		userInfo(e) {
			value.value.alertUserInfo = e.currentTarget.dataset.userinfo;
			uni.navigateTo({
				url: '/pages/addUser/addUser?userinfo=true'
			});
		},
		deleUser(e) {
			const that = this;
			const userid = e.currentTarget.dataset.userid;
			uni.showModal({
				title: '提示',
				content: '确定删除该联系人吗？',
				success(res) {
					if (res.confirm) {
						let obj = {
							takemanId: e.currentTarget.dataset.userid,
							ticks: utils.utils.GetTicks(),
							channel: 'Xcx'
						};
						obj.sign = utils.utils.GetSign(obj);
						that.$http
							.request({
								url: `/Member/DeleteTakeMan`,
								method: 'post',
								data: obj
							})
							.then(res => {
								that.getData();
							})
							.catch(err => {
								console.log(err);
							});
					}
				}
			});
		},
		addUser() {
			uni.navigateTo({
				url: '/pages/addUser/addUser'
			});
		}
	}
};
</script>
<style scoped>
.userCheck {
	width: 95%;
	margin: 0 auto;
}
.modifyView {
	display: inline-block;
	width: 50upx;
	height: 50upx;
}
.imgBody {
	position: absolute;
	top: 14upx;
	right: 40upx;
}
.modifyView > image {
	width: 100%;
	height: 100%;
}
.userName {
	height: 50upx;
	line-height: 50upx;
}
.itemUser {
	height: 120upx;
	line-height: 120upx;
	position: absolute;
	top: 20upx;
}
.userTop {
	line-height: 100upx;
	width: 95%;
	margin: 0 auto;
}
.addUser {
	width: 95%;
	background-color: #01a1e9;
	height: 90upx;
	line-height: 90upx;
	margin: 0 auto;
	font-size: 34upx;
	color: #ffffff;
	text-align: center;
	border-radius: 10upx;
	margin-top: 60upx;
}
.userLabel {
	background-color: #ffffff;
	width: 95%;
	margin: 10upx auto 0upx auto;
	height: 140upx;
	line-height: 140upx;
	position: relative;
	border-radius: 10upx;
	padding-left: 40upx;
	border-bottom: 1px solid #d9d9d9;
	/* padding-bottom: 10upx; */
}
.userLabel:last-child {
	border: none;
	padding-bottom: 30upx;
}
</style>
